package cn.com.surker.production.entity.report;

import cn.com.surker.base.ExportInter;
import cn.com.surker.excel.ExcelCell;
import cn.com.surker.production.entity.vo.ProductionIndentVo;
import cn.com.surker.util.MathUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * 任务单的统计数据
 *
 * @author luotao
 * @date 2024/12/5
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class ProductionIndentReport extends ProductionIndentVo implements ExportInter {

	/**
	 * 累计生产方量
	 */
	@ExcelCell(value = "生产方量", sort = 8, calcTotal = true)
	private Double proStere;

	/**
	 * 发货方量
	 */
	@ExcelCell(value = "发货方量", sort = 9, calcTotal = true)
	private Double sendStere;

	/**
	 * 砼方量
	 */
	// @ExcelCell(value = "砼方量", sort = 10)
	// private Double concreteStere;

	/**
	 * 砂浆方量
	 */
	@ExcelCell(value = "砂浆方量", sort = 11, calcTotal = true)
	private Double mortarStere;

	/**
	 * 水方量
	 */
	@ExcelCell(value = "水方量", sort = 12, calcTotal = true)
	private Double waterStere;

	/**
	 * 工地签收方量
	 */
	@ExcelCell(value = "工地签收方量", sort = 13, calcTotal = true)
	private Double signStere;

	/**
	 * 工地实际使用方量,
	 * 计算方式:实际生产方量+转入方量-过磅退回方量
	 */
	@ExcelCell(value = "工地实际使用方量", sort = 14, calcTotal = true)
	private Double realUseStere;

	public Double getRealUseStere() {
		//	总方量
		Double totalStere = MathUtils.add(getProStere(), getInStere());
		//	退回方量
		realUseStere = MathUtils.subtract(totalStere, getWeightReStere());
		return realUseStere;
	}

	/**
	 * 过磅退回方量
	 */
	@ExcelCell(value = "过磅退回方量", sort = 15, calcTotal = true)
	private Double weightReStere;

	/**
	 * 客户退回方量
	 */
	@ExcelCell(value = "客户退回方量", sort = 16, calcTotal = true)
	private Double buildReStere;

	/**
	 * 退回量差
	 * 计算方式
	 */
	@ExcelCell(value = "退回量差", sort = 17, calcTotal = true)
	private Double reDiffStere;

	/**
	 * 施工方退回已签方量
	 * 计算方式:签收方量-发货量差-实际使用方量
	 */
	@ExcelCell(value = "退回已签", sort = 18, calcTotal = true)
	private Double buildReSign;

	public Double getBuildReSign() {
		//	签收方量
		Double signStere = getSignStere();
		//	发货量差
		Double sendDiffStere = getSendDiffStere();
		//	实际使用
		Double realUseStere = getRealUseStere();
		Double a = MathUtils.subtract(signStere, sendDiffStere);
		buildReSign = MathUtils.subtract(a, realUseStere);
		return buildReSign;
	}

	/**
	 * 施工方退回未签
	 * 计算方式:退回方量-退回已签
	 */
	@ExcelCell(value = "退回未签", sort = 19, calcTotal = true)
	private Double buildReNoSign;

	public Double getBuildReNoSign() {
		//	施工方退回方量
		Double buildReStere = getBuildReStere();
		Double buildReSign = getBuildReSign();
		buildReNoSign = MathUtils.subtract(buildReStere, buildReSign);
		return buildReNoSign;
	}

	/**
	 * 转入方量
	 */
	@ExcelCell(value = "转入方量", sort = 20)
	private Double inStere;

	/**
	 * 转出方量
	 */
	@ExcelCell(value = "转出方量", sort = 21)
	private Double outStere;

	/**
	 * 作废方量
	 */
	@ExcelCell(value = "作废方量", sort = 22, calcTotal = true)
	private Double scrapStere;

	/**
	 * 运输或者泵送结算方量,计算方式为小票发货方量-过磅退回方量
	 */
	@ExcelCell(value = "车队结算方量", sort = 23, calcTotal = true)
	private Double carBillStere;

	public Double getCarBillStere() {
		carBillStere = MathUtils.subtract(sendStere, weightReStere);
		return carBillStere;
	}

	/**
	 * 累计任务
	 */
	private Integer indentTotal;
	/**
	 * 累计车次,累计车次以及累计方量采用计算的方式,不写死
	 */
	private Integer totalCar;

	/**
	 * 发货量差,发货量差=发货方量-实际生产量
	 *
	 * @return
	 */
	private Double sendDiffStere;

	public Double getSendDiffStere() {
		Double sendStere = getSendStere();
		//	总方量
		Double totalStere = MathUtils.add(getProStere(), getInStere());
		Double subtract = MathUtils.subtract(sendStere, totalStere);
		return subtract;
	}

	public Double getSignStere() {
		if (signStere != null) {
			signStere = MathUtils.decimal(signStere);
		}
		return signStere;
	}

	/**
	 * 生产时间
	 */
	private Date proTime;
}
